package com.ruoyi.factory.common.task;

import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.factory.apilog.domain.ApiLog;
import com.ruoyi.factory.apilog.service.IApiLogService;
import com.ruoyi.framework.manager.factory.AsyncFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.TimerTask;

/**
 * @Description: {开启异步任务}
 * @Author: fengchengwu2012@163.com
 * @Time: 2020/3/13 12:07
 */
public class AsyncFactoryLog extends AsyncFactory {

    private static final Logger LOGGER = LoggerFactory.getLogger("sys-info");

    /**
     * 异步存储支付api日志
     *
     * @param apiLog
     * @return
     */
    public static TimerTask recordApiLog(final ApiLog apiLog) {
        return new TimerTask() {
            @Override
            public void run() {
                SpringUtils.getBean(IApiLogService.class).insertApiLog(apiLog);
            }
        };
    }
}
